//
// Created by 陈成 on 2019/9/19.
//

#ifndef RV32I_CPU_INST_H
#define RV32I_CPU_INST_H

#include "systemc.h"
#include "RegBank.hpp"
#include "Mem.h"
#include "Comm.h"
#include "log.h"

class Inst {
public:
    Inst(uint32_t pc, sc_bv<32> inst, RegBank<REG_NUM> *r, RegBank<CSR_NUM> *csr, Mem *m);

    virtual uint32_t
    exec() = 0;

protected:
    RegBank<REG_NUM> *r;
    RegBank<CSR_NUM> *csr;
    Mem *m;
    uint32_t pc;

    sc_bv<32>
    extendImm(sc_bv<12> imm);

    sc_bv<32>
    extendImm(sc_bv<21> imm);

    sc_bv<32>
    extendImm(sc_bv<16> imm);

    sc_bv<32>
    extendImm(sc_bv<8> imm);
};


#endif //RV32I_CPU_INST_H
